package com.macro.mall.remote;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.common.es.EsAddDocDto;
import com.macro.mall.common.es.EsIndexDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @Author：hwh
 * @Description: es远程调用
 * @name：EsAddDocRemote
 * @Date：2024/10/17 17:10
 */
@FeignClient (name = "mall-es")
public interface EsRemoteService {
    /**
     * 批量添加文档
     * @param esAddDocDto 包含要添加的文档信息
     * @return CommonResult
     */
    @PostMapping("/esQuery/batchSave")
    public ResponseEntity<CommonResult<String>> batchSave(@Validated @RequestBody EsAddDocDto esAddDocDto);

    /**
     * 创建索引
     * @param esIndexDto 包含索引信息
     * @return CommonResult
     * @throws IOException
     */
    @PostMapping("/esIndex/creatIndex")
    public CommonResult createIndex(@Validated @RequestBody EsIndexDto esIndexDto);

    /**
     * 删除索引
     *
     * @param indexName
     * @return
     */
    @DeleteMapping("/esIndex/delIndex")
    public boolean delIndex( @RequestParam String indexName);

    /**
     * 查询索引信息
     * @param indexName 索引名称
     * @return CommonResult
     */
    @GetMapping("/esIndex/getInfo")
    public CommonResult getInfo( @RequestParam String indexName);
}
